package me.principality.webapp.response

class ResultData<T> {
    /** 结果状态 ,具体状态码参见ResultData */
    var status = 0
    var message: String? = null
    var data: T? = null

    companion object {
        fun <T> success(data: T): ResultData<T> {
            val resultData: ResultData<T> = ResultData()
            resultData.status = ReturnCode.RC100.code
            resultData.message = ReturnCode.RC100.message
            resultData.data = data
            return resultData
        }

        fun <T> fail(code: Int, message: String?): ResultData<T> {
            val resultData: ResultData<T> = ResultData()
            resultData.status = code
            resultData.message = message
            return resultData
        }
    }
}